<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
	<title>jQuery 확장하기</title>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
	<script type="text/javascript">
	$.fn.readonly = function(b) {
		if (b == undefined) {
			b = true;
		}
		return this.each(function() {
			if (b) {
				$(this).attr("readonly", "readonly");
			} else {
				$(this).removeAttr("readonly");
			}
		});
	};
	</script>
</head>
<body>
	<input id="textInput" />
	<button id="btnSetReadonly" onclick="$('#textInput').readonly(true);">
		readonly 설정</button>
	<button id="btnRemoveReadonly" 
		onclick="$('#textInput').readonly(false);">readonly 제거</button>
</body>
</html>